<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.9/vue.js"></script>
</head>

<body>
    <div id="app">
        <!-- 页面打开自动聚焦 -->
        <input type="text" v-focus>
        <!-- 页面打开输入框有颜色 -->
        <input type="text" v-color="{color:'skyblue'}">
    </div>
    <script>
        new Vue({
            el: '#app',
            directives: {
                focus: {
                    inserted(el) {
                        el.focus()
                    }
                },
                color: {
                    inserted(el, binding) {
                        console.log(binding);
                        el.style.background = binding.value.color
                    }
                }
            }
        })
    </script>
</body>

</html>